import Vue from 'vue'
import VueRouter from 'vue-router'

const Home = () => import ('../views/home/Home')
const Category = () => import ('../views/Category')
const Shopcart = () => import ('../views/Shopcart')
const Profile = () => import ('../views/Profile')
const Detail = () => import ('../views/detail/Detail')

// 1.安装插件
Vue.use(VueRouter)

//2.创建路由对象
const router = new VueRouter({
  routes: [
    {
      path: '',
      redirect: '/home',
    },
    {
      path: '/home',
      component: Home,
      meta: {
        title: '首页'
      }
    },
    {
      path: '/category',
      component: Category,
      meta: {
        title: '类别'
      }
    },
    {
      path: '/shopcart',
      component: Shopcart,
      meta: {
        title: '购物车'
      }
    },
    {
      path: '/profile',
      component: Profile,
      meta: {
        title: '我的'
      }
    },
    {
        path:'/detail/:iid',
        component: Detail
    }
  ],
  mode: 'history'
})

// 3、导出router
export default router